﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class OdGsWriter : IDisposable
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdGsWriter(IntPtr cPtr, bool cMemoryOwn)
		{
			this.swigCMemOwn = cMemoryOwn;
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdGsWriter obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdGsWriter()
		{
			this.Dispose();
		}

		public virtual void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.delete_OdGsWriter(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
		}

		public OdGsWriter() : this(GlobalsPINVOKE.new_OdGsWriter(), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdGsExtAccum extentsAccum()
		{
			OdGsExtAccum result = new OdGsExtAccum(GlobalsPINVOKE.OdGsWriter_extentsAccum(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGsBaseModel gsModel()
		{
			IntPtr intPtr = GlobalsPINVOKE.OdGsWriter_gsModel(this.swigCPtr);
			OdGsBaseModel result = (intPtr == IntPtr.Zero) ? null : new OdGsBaseModel(intPtr, false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool isRecordingMetafile()
		{
			bool result = GlobalsPINVOKE.OdGsWriter_isRecordingMetafile(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void beginMetafileRecording(OdGsGeomPortion pGeomPortion)
		{
			GlobalsPINVOKE.OdGsWriter_beginMetafileRecording(this.swigCPtr, OdGsGeomPortion.getCPtr(pGeomPortion));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void endMetafileRecording()
		{
			GlobalsPINVOKE.OdGsWriter_endMetafileRecording(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void onNestedDrawable(OdDbStub layerId)
		{
			GlobalsPINVOKE.OdGsWriter_onNestedDrawable(this.swigCPtr, OdDbStub.getCPtr(layerId));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public bool isLayerFrozen(OdGsLayerNode pLayerNode)
		{
			bool result = GlobalsPINVOKE.OdGsWriter_isLayerFrozen(this.swigCPtr, OdGsLayerNode.getCPtr(pLayerNode));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGsBaseModel m_pGsModel
		{
			get
			{
				IntPtr intPtr = GlobalsPINVOKE.OdGsWriter_m_pGsModel_get(this.swigCPtr);
				OdGsBaseModel result = (intPtr == IntPtr.Zero) ? null : new OdGsBaseModel(intPtr, false);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}
			set
			{
				GlobalsPINVOKE.OdGsWriter_m_pGsModel_set(this.swigCPtr, OdGsBaseModel.getCPtr(value));
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}
		}

		private object locker = new object();

		private HandleRef swigCPtr;

		protected bool swigCMemOwn;
	}
}
